<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>这是项目的首页</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!-- <meta http-equiv="refresh" content="3;url=showAlls" />s -->
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script src="<%=basePath%>js/bootstrap-select.js"></script>
    <link rel="stylesheet" href="<%=basePath%>css/bootstrap-select.css"/>
    <link rel="stylesheet" href="<%=basePath%>css/bosIndex.css"/>
    <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="<%=basePath%>css/combo.select.css">
    <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        //将id传给后台
        function findById(id) {
            document.getElementById("id").value = id;
            var form1 = document.getElementById("form1");
            form1.submit();
        }

        //11.根据id删除数据
        function deleteByID(id) {
            var f = confirm("你确认要删除吗？");
            if (f) {
                location.href = "deleteByid/" + id;

            }

        }

        //点击进行评论的功能(将关联的id 和用户登陆名name 和项目名称传过去传过去)
        function addComment(id, name, wname) {

            var cid = document.getElementById("cid").value = id;
            var cname = document.getElementById("cname").value = name;
            var wname = document.getElementById("wname").value = wname;
            var findC = document.getElementById("findC");
            findC.submit();
        }

        //操作日志，调用后台接口
        function findAllLog() {
            //alert("111");
            location.href = "findLogs";

        }


        /*下拉列表js代码*/
        $(window).on('load', function () {
            $('.selectpicker').select({
                'selectedText': 'cat'
            });

        });

        //将项目id传给后台(用来做添加新字段的功能)
      /*  function sendPid() {
            location.href = "sendPid";
        }

        function delColumn() {
            location.href = "findAllColumn";
        }*/

        //进行导出Excel的操作
        function excel(type) {
            var form = document.getElementById("form2");
            form.action = "selectByWhere2/" + type;
            form.submit();

        }

        //进行导出所有Excel的操作
        function excelAll() {
            var type = 1;
            var form = document.getElementById("form2");
            var condition = document.getElementById("condition").value;
            form.action = "selectByWhere2";
            form.submit();

        }

        //根据条件多条件查询
        function selectBywhere() {
            var forms = document.getElementById("form2");
            forms.action = "selectByWhere";
            forms.submit();
        }

        //重置
        function resetAll() {
            location.href="showAll";
        }

        function gotoPage(pageNo) {
            if (pageNo == 0) {
                document.getElementById("pageNo").value = document.getElementById("inputPage").value;
                document.getElementById("setPageSize").value = document.getElementById("getPageSize").value;
            } else {
                document.getElementById("pageNo").value = pageNo;
            }
            var forms = document.getElementById("form2");
            forms.action = "selectByWhere";
            forms.submit();
        }

        function copyOne(id) {
            location.href="copyProject/"+id;
        }
    </script>
    <script src="<%=basePath%>js/jquery-1.11.3.min.js"></script>
    <script src="<%=basePath%>js/jquery.combo.select.js"></script>
    <script>
        $(function() {
            $('select').comboSelect();
        });
    </script>

</head>

<body>
<div class="box">
    <span class="home"><a href="<%=basePath%>tojump">首页</a></span>
    <div class="caozuo">
        <span><a href="javaScript:findAllLog()">操作日志</a></span>
        <span><a href="javaScript:excel(1)">导出当前页</a></span>
        <span><a href="javaScript:excel(2)">导出所有</a></span>
    </div>
    <div class="title">
        项目列表
    </div>
    <!-- 这是用来做索引查询的     -->
    <div class="projects_nav">
        <form method="post" id="form2">

            <!--搜索输入框-->
            <input class="search" type="text" name="condition" id="condition" value="${condition}"/>
            <input type="hidden" name="pageNo" id="pageNo" value="${list.pageNo}"/>
            <input type="hidden" name="setPageSize" id="setPageSize" value="${list.pageSize}"/>
            <input type="hidden" name="btnStatus" id="btnStatus" value="${sessionScope.btnStatus}"/>
            <div><input type="button" name="" id="link" value="筛选"></div>
            <!--条件搜索-->
            <input class="searchBtn" type="button" value="搜索" onclick="selectBywhere()"/>
            <input class="searchBtn" type="button" value="重置" onclick="resetAll()"/>
            <a class="add_btn" href="toUser">添加新项目</a>
            <div id="thediv" style="display: none;">
                <div class="left-so">
                    <span>项目进度:</span>
                    <c:forEach var="c" items="${progress}" varStatus="status" begin="0">
                        <c:if test="${status.index==0}"><li class="li"></c:if>
                        <c:if test="${status.index%3==0}"></li>
                            <li class="li"></c:if>
                        <input type="checkbox" value="${c.paramValue}" name="start"
                               <c:if test="${fn:indexOf(requestScope.start,c.paramValue)!='-1'}">checked="checked"</c:if>/><span>${c.paramValue}</span>
                        <c:if test="${fn:length(progress)-1==status.index}"></li></c:if>
                    </c:forEach>
                    <span>项目组:</span>
                    <c:forEach var="c" items="${pGroups}" varStatus="status" begin="0">
                        <c:if test="${status.index==0}">
                            <li class="li"></c:if>
                        <c:if test="${status.index%2==0}"></li>
                            <li class="li"></c:if>
                        <input type="checkbox" value="${c.paramValue}" name="pteam"
                               <c:if test="${fn:indexOf(requestScope.pteam,c.paramValue)!='-1'}">checked="checked"</c:if>/><span>${c.paramValue}</span>
                        <c:if test="${fn:length(pGroups)-1==status.index}"></li></c:if>
                    </c:forEach>
                </div>
                <div class="right-so">
                    <span>工作类别:</span>
                    <c:forEach var="c" items="${pType}" varStatus="status" begin="0">
                        <c:if test="${status.index==0}">
                            <li class="li"></c:if>
                        <c:if test="${status.index%3==0}"></li>
                            <li class="li"></c:if>
                        <input type="checkbox" value="${c.paramValue}" name="wtype"
                               <c:if test="${fn:indexOf(requestScope.wtype,c.paramValue)!='-1'}">checked="checked"</c:if>/><span>${c.paramValue}</span>
                        <c:if test="${fn:length(pType)-1==status.index}"></li></c:if>
                    </c:forEach>
                    <span>项目负责人:</span>
                    <div id="select">
                        <div class="dowebok">
                            <select  class="select" name="pleader">
                                <option value="">----请选择----</option>
                                <c:forEach var="c" items="${sessionScope.leaders}">
                                    <option value="${c.leader}"
                                   <c:if test="${fn:indexOf(requestScope.pleader,c.leader)!='-1'}">selected="selected"</c:if>>${c.leader}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>

                </div>

            </div>
        </form>
        <script type="text/javascript">

            window.onload = function () {
                var status='${sessionScope.btnStatus}';

                var olink = document.getElementById("link");
                var odiv = document.getElementById("thediv");
                if(status!='' && status!=null){
                    odiv.style.display=status;
                }

                olink.onclick = function () {
                    if (odiv.style.display == "none") {
                        odiv.style.display = 'block';
                    } else {
                        odiv.style.display = 'none';
                    }
                    var status2=odiv.style.display;
                    document.getElementById("btnStatus").value=status2;
                    return false;
                };
                var b = 0;
                $("#button").click(function () {
                    alert("1111");
                    console.log($("#sname").val().length);
                    if ($("#status").val().length == 0 || $("#sname").val().length == 0 || $("#stype").val().length == 0 || $("#money").val().length == 0 || $("#sleader").val().length == 0 || $("#content").val().length == 0 || $("#point").val().length == 0 || $("#target").val().length == 0) {
                        alert('仔细填写');

                    } else {
                        var insertForm1 = document.getElementById("insertForm1");
                        insertForm1.submit();
                    }
                });
            }
            var count = 0;
        </script>
    </div>

    <form action="findComment" method="post" id="findC">
        <input type="hidden" name="cid" id="cid"/>
        <input type="hidden" name="cname" id="cname"/>
        <input type="hidden" name="wname" id="wname"/>
    </form>

    <form:form action="findProjectById" method="post" id="form1">
        <input type="hidden" name="id" id="id"/>
    </form:form>


    <table class="t_box">
        <thead class="pro-top">
        <tr>
            <th><input type="checkbox" value=""/></th>
            <th>序号</th>
            <th>项目组</th>
            <th>项目进度</th>
            <th>工作类别</th>
            <th>项目名称</th>
            <th>项目情况</th>
            <th>项目开始时间</th>
            <th>交付时间</th>
            <th>项目负责人</th>
            <th>审核人</th>
            <th>客户负责人</th>
            <th>订阅人</th>
            <%--<th>其他2</th>其他2不显示--%>
            <th>备注说明</th>
          <%--  <c:forEach var="c" items="${column}">
                <th>${c.prop}</th>
            </c:forEach>--%>
            <th>操作</th>
        </tr>
        </thead>
        <tbody class="pro_tbody">
        <c:forEach items="${list.data}" var="v" varStatus="status">
            <tr class="tr">
                <td><input type="checkbox" value=""/></td>
                <td>${status.index+1}</td>
                <td>${v.groups}</td>
                <td>${v.progess}</td>
                <td>${v.wType}</td>
                <td class="czl">${v.wName}</td>
                <td style="width:16%;height:30%">${v.pdetail}</td>
                <td>${v.sTime}</td>
                <td>${v.eTime}</td>
                <td id="leader">${v.leader}</td>
                <td>${v.checker}</td>
                <td>${v.kehuer}</td>
                <td>${v.others1}</td>
                <%--<td>${v.others2}</td>其他2不显示--%>
                <td>${v.remarks}</td>
               <%-- <c:forEach var="c" items="${proItems}">
                    <c:if test="${c.proid==v.id}">
                        <td>${c.value}</td>
                    </c:if>
                </c:forEach>--%>
                <td class="czl">
                    <a href="javaScript:findById(${v.id})">修改</a><span>&nbsp;|</span>
                    <a href="javaScript:deleteByID(${v.id})">删除</a><span>&nbsp;|</span>
                    <a href="javaScript:addComment('${v.id}','${user.name}','${v.wName}')">评论</a>
                    <a href="javaScript:copyOne(${v.id})">复制</a>
                </td>
            </tr>

        </c:forEach>
        </tbody>
    </table>
    <!-- 引入分页 -->
    <jsp:include page="jsp/page.jsp" flush="true"/>

</div>
</body>
</html>
